package com.gk.controller2;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gk.bean.GuoYaoBackDto.*;
import com.gk.service.GuoYaoBackWriteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("GuoYaoBackWrite")
@Api(tags = "国药回写")
@Slf4j
public class GuoYaoBackWriteController {

    @Resource
    private GuoYaoBackWriteService guoYaoBackWriteService;

    @PostMapping("/backWriteMaintenanceRecord")
    @ApiOperation(value = "质量养护记录", response = GHttpResult.class)
    public GHttpResult backWriteMaintenanceRecord(@RequestBody GuoYaoRequestParams<ZxyZlyhjlGuoyao> requestParams, @RequestHeader("id") String id) {
        log.info("质量养护记录controller:" + requestParams);
        List<ZxyZlyhjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteMaintenanceRecord(list);
    }

    @PostMapping("/backWriteBuyBackOrLossRecord")
    @ApiOperation(value = "质量购进退出及报损复核记录", response = GHttpResult.class)
    public GHttpResult backWriteBuyBackOrLossRecord(@RequestBody GuoYaoRequestParams<ZxyZlbuybackandbaosunreviewjlGuoyao> requestParams, @RequestHeader("id") String id) {
        log.info("质量购进退出及报损复核记录controller:" + requestParams);
        List<ZxyZlbuybackandbaosunreviewjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteBuyBackOrLossRecord(list);
    }

    @PostMapping("/backWriteDisQualifiedRecord")
    @ApiOperation(value = "质量不合格记录", response = GHttpResult.class)
    public GHttpResult backWriteDisQualifiedRecord(@RequestBody GuoYaoRequestParams<ZxyZlnoqualifiedjlGuoyao> requestParams, @RequestHeader("id") String id) {
        log.info("质量不合格记录controller:" + requestParams);
        List<ZxyZlnoqualifiedjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteDisQualifiedRecord(list);
    }

    @PostMapping("/backWriteSaleBackRecord")
    @ApiOperation(value = "销售退回记录", response = GHttpResult.class)
    public GHttpResult backWriteSaleBackRecord(@RequestBody GuoYaoRequestParams<ZxyZlsalebackjlGuoyao> requestParams, @RequestHeader("id") String id) {
        log.info("销售退回记录controller:" + requestParams);
        List<ZxyZlsalebackjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteSaleBackRecord(list);
    }

    @PostMapping("/backWriteSaleReviewRecord")
    @ApiOperation(value = "销售出库复核记录", response = GHttpResult.class)
    public GHttpResult backWriteSaleReviewRecord(@RequestBody GuoYaoRequestParams<ZxyZlsalereviewjlGuoyao> requestParams, @RequestHeader("id") String id) {
        log.info("销售出库复核记录controller:" + requestParams);
        List<ZxyZlsalereviewjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteSaleReviewRecord(list);
    }

    @PostMapping("/backWriteBuyCheckedRecord")
    @ApiOperation(value = "采购验收记录", response = GHttpResult.class)
    public GHttpResult backWriteBuyCheckedRecord(@RequestBody GuoYaoRequestParams<ZxyZlbuyzlysjlGuoyao> requestParams, @RequestHeader("id") String id) {
        log.info("采购验收记录controller:" + requestParams);
        List<ZxyZlbuyzlysjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteBuyCheckedRecord(list);
    }

    @PostMapping("/backWriteBuyReceiveRecord")
    @ApiOperation(value = "采购收货记录", response = GHttpResult.class)
    public GHttpResult backWriteBuyReceiveRecord(@RequestBody GuoYaoRequestParams<ZxyZlbuyshjlGuoyao> requestParams, @RequestHeader("id") String id) {

        log.info("采购收货记录controller:" + requestParams);
        List<ZxyZlbuyshjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteBuyReceiveRecord(list);
    }


    @PostMapping("/backWriteTransportRecord")
    @ApiOperation(value = "运输记录", response = GHttpResult.class)
    public GHttpResult backWriteTransportRecord(@RequestBody GuoYaoRequestParams<ZxyZlwtysjlGuoyao> requestParams, @RequestHeader("id") String id) {
        log.info("运输记录controller:" + requestParams);
        List<ZxyZlwtysjlGuoyao> list = requestParams.getDatalist();
        return guoYaoBackWriteService.backWriteTransportRecord(list);
    }

//    @PostMapping("/backWriteGoodsStocks")
//    @ApiOperation(value = "库存清单记录", response = GHttpResult.class)
//    public GHttpResult backWriteGoodsStocks(@RequestBody RequestParams<ZxyZlgoodsstocksGuoyao> aa, @RequestHeader("id") String id) {
//        log.info("库存清单记录controller:" + aa);
//
//        return guoYaoBackWriteService.backWriteGoodsStocks(aa.getDatalist());
//    }


}
